/*
 This file 'Component' is part of Firebird Integrated Solution 1.0

 Copyright (c) 2014 Lincong

 Contact:  
 Email: lincong1987@gmail.com

 QQ: 159257119

 See Usage at http://www.jplatformx.com/firebird

 Create date: 2014-06-23 10:09
 */

define(function (require, exports, module) {

	var $ = require("jquery");
	var jqui = require("jquery.ui");

	var Model = require("Firebird.Model");

	/**
	 * Firebird.ui.Component
	 * @class Firebird.ui.Component
	 */
	Firebird.define("Firebird.ui.Component", {
		statics: {
			zIndex: 200,
			getZIndex: function () {
				return this.zIndex++;
			},
			eval: function (data) {
				if (data === false) {
					return false;
				}
				if (data === true) {
					return true;
				}
				if (!data) {
					return null;
				}
				if (data === "") {
					return "";
				}
				if (data === "true") {
					return true;
				}
				if (data === "false") {
					return false;
				}
				if (!isNaN(data)) {
					return Number(data);
				}
				var rs = null;
				var $className = "";
				try {
					$className = arguments.callee.caller.$owner.$className;
				} catch (e) {
				}
				try {
					// if (a) {
					// 	rs = (new Function(a, "//以下你看到的代碼是經過包装的。\nreturn " + data))(a);
					// } else {
					// var args = $.makeArray(arguments);
					// args[args.length - 1] = "debugger;//以下你看到的代碼是經過包装的。\nreturn " + args[args.length - 1];
					// var func = Function.apply(this, args);
					//
					// rs = (func).apply(func, args);
					// }

					rs = (new Function("//以下你看到的代碼是經過包装的。\nreturn " + data))();

				} catch (e) {
					firebird.error($className + " 属性标签解析失败:" + data + "\n" + e.message);
					// + "\n\n请复制一下代码，运行一下\n\nnew Function(\"return " + data + "\")"
				}
				return rs;
			}
		},
		extend: "Firebird.Model",
		isPlaceholderSupport: false//'placeholder'in document.createElement('input')
	});

	module.exports = Firebird.ui.Component;
});